<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Car;
use App\Phone;
use App\Bor;

class IndexController extends Controller
{

    public function index()
    {
        $buycar = new Car();
        $ishot = $buycar->where('ishot','=','1')->take(6)->get();
        $isshow = $buycar->where('isshow','=','1')->take(6)->get();
        $isrecom = $buycar->where('isrecom','=','1')->take(6)->get();
        $iscar =  $buycar->get();
        // dd($iscar);
  return view('home.index',['ishot'=>$ishot,'isshow'=>$isshow,'isrecom'=>$isrecom,'iscar'=>$iscar]);
    }
    //首页卖车手机号入库
    public function phone(Request $req){
        $ph = new Phone();
        $phone = $req->phone;
        $ph->phoneone = $phone;
        $ph->addtime= date('Y-m-d');
        $ph->save();
    }

        //卖车页面手机号入库
    public function phonetwo(Request $req){
        $ph = new Phone();
        $phone = $req->phone;
        $ph->phonetwo = $phone;
        $ph->addtime= date('Y-m-d');
        $ph->save();
    }

        public function tomoney(Request $req){
        $money = $req->nameArr['0'];//0为money的值
        $month = $req->nameArr['1'];//1为month的值
        $phone = $req->nameArr['2'];//2为money的值
        // dd($req);die;
        $bor = new Bor();
        $bor->username = "NULL";
        $bor->money = $money;
        $bor->month = $month;
        $bor->phone = $phone;
        $bor->save();
    }

}
